package com.ae.shield.common.items;

import com.ae.shield.AEShieldMod;
import com.ae.shield.ModLib;
import com.ae.shield.common.block.BlockList;
import com.ae.shield.common.fluid.NitrogenFluid;
import com.ae.shield.common.items.shieldFittings.rectifier.Amplifier;
import com.ae.shield.common.items.shieldFittings.rectifier.CapacitorBank;
import com.ae.shield.common.items.shieldFittings.rectifier.DefenseAssistant;
import com.ae.shield.common.items.shieldFittings.rectifier.EmergencyLifeSupportSystem;
import com.ae.shield.common.items.shieldFittings.makers.*;
import com.ae.shield.common.items.shieldFittings.SuffixItem;
import com.ae.shield.common.items.util.ToolItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

import java.util.ArrayList;
import java.util.function.Supplier;

public class ItemList {
    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ModLib.MOD_ID);
    public static final ArrayList<RegistryObject<Item>> COLOR = new ArrayList<>();

    public static final RegistryObject<Item> SHIELD = register("shield", ItemIntegratedShield::new);
    public static final RegistryObject<Item> PARTICLE_SHIELD = register("particle_shield", ParticleShield::new);
    public static final RegistryObject<Item> ENERGY_SHIELD = register("energy_shield", EnergyShield::new);
    public static final RegistryObject<Item> PLASMA_SHIELD = register("plasma_shield", PlasmaShield::new);
    public static final RegistryObject<Item> FIELD_SHIELD = register("field_shield", FieldShield::new);
    public static final RegistryObject<Item> NANO_ROBOT = register("nano_robot", NanoRobot::new);
    public static final RegistryObject<Item> ANTI_MAGIC_SHIELD = register("anti_magic_shield", AntiMagicShield::new);
    public static final RegistryObject<Item> HEV = register("hev", HEV::new);
    public static final RegistryObject<Item> UNDYING_PROTECTION = register("undying_protection", UndyingProtection::new);
    public static final RegistryObject<Item> RUBBISH_SHIELD = register("rubbish_shield", RubbishShield::new);
    public static final RegistryObject<Item> CREATE_SHIELD = register("create_shield", CreateShield::new);
    public static final RegistryObject<Item> AMPLIFIER = register("amplifier", Amplifier::new);
    public static final RegistryObject<Item> DEFENSE_ASSISTANT = register("defense_assistant", DefenseAssistant::new);
    public static final RegistryObject<Item> CAPACITOR_BANK = register("capacitor_bank", CapacitorBank::new);
    public static final RegistryObject<Item> EMERGENCY_LIFE_SUPPORT_SYSTEM = register("emergency_life_support_system", EmergencyLifeSupportSystem::new);
    public static final RegistryObject<Item> NANO_TOOL = register("nano_tool", NanoTool::new);
    public static final RegistryObject<Item> EFFECT_STORAGE_ITEM = register("effect_storage_item", EffectStorageItem::new);
    public static final RegistryObject<Item> SUFFIX_KID = register("suffix_kid", SuffixItem::new);
    public static final RegistryObject<Item> INTENSIFIED_SUFFIX_KID = register("intensified_suffix_kid", SuffixItem::new);

    //材料-初级
    //粒
    public static final RegistryObject<Item> NUGGETS_ENDERIUM = register("nuggets_enderium", 0x2ccdb1);
    public static final RegistryObject<Item> NUGGETS_NANO = register("nuggets_nano", 0x4b4b4b);
    //线
    public static final RegistryObject<Item> WIRES_IRON = register("wire_iron", 0xffffff);
    public static final RegistryObject<Item> WIRES_GOLD = register("wire_gold");
    public static final RegistryObject<Item> WIRES_NANO = register("wire_nano", 0x4b4b4b);
    //粉
    public static final RegistryObject<Item> DUSTS_IRON = register("dusts_iron", 0xffffff);
    public static final RegistryObject<Item> DUSTS_ALUMINUM = register("dusts_aluminum", 0xd6d6d6);
    public static final RegistryObject<Item> DUSTS_GOLD = register("dusts_gold");
    public static final RegistryObject<Item> DUSTS_MANGANESE = register("dusts_manganese",0x9f9f9f);
    public static final RegistryObject<Item> DUSTS_TANTALUM = register("dusts_tantalum",0xbacfbf);
    public static final RegistryObject<Item> DUSTS_ENDERIUM = register("dusts_enderium", 0x2ccdb1);
    public static final RegistryObject<Item> DUSTS_SILVER = register("dusts_silver", 0xffffff);
    //锭
    public static final RegistryObject<Item> INGOTS_TIN = register("ingots_tin", 0xaeeaf6);
    public static final RegistryObject<Item> INGOTS_LEAD = register("ingots_lead", 0x8092e4);
    public static final RegistryObject<Item> INGOTS_ALUMINUM = register("ingots_aluminum", 0xd6d6d6);
    public static final RegistryObject<Item> INGOTS_SILVER = register("ingots_silver", 0xffffff);
    public static final RegistryObject<Item> INGOTS_MANGANESE = register("ingots_manganese", 0x9f9f9f);
    public static final RegistryObject<Item> INGOTS_TANTALUM = register("ingots_tantalum", 0xbacfbf);
    public static final RegistryObject<Item> INGOTS_ENDERIUM = register("ingots_enderium", 0x2ccdb1);
    public static final RegistryObject<Item> INGOTS_NANO = register("ingots_nano", 0x4b4b4b);
    //板
    public static final RegistryObject<Item> PLATES_LEAD = register("plates_lead", 0x8092e4);
    public static final RegistryObject<Item> PLATES_IRON = register("plates_iron", 0xffffff);
    public static final RegistryObject<Item> PLATES_GOLD = register("plates_gold");
    public static final RegistryObject<Item> PLATES_ENDERIUM = register("plates_enderium", 0x2ccdb1);
    public static final RegistryObject<Item> PLATES_NANO = register("plates_nano", 0x4b4b4b);
    public static final RegistryObject<Item> PLATES_DENSE_LEAD = register("plates_dense_lead", 0x8092e4);
    public static final RegistryObject<Item> PLATES_DENSE_ENDERIUM = register("plates_dense_enderium", 0x2ccdb1);
    public static final RegistryObject<Item> PLATES_DENSE_NANO = register("plates_dense_nano", 0x4b4b4b);
    //其他
    public static final RegistryObject<Item> SOLDER_BALL = register("solder_ball");
    public static final RegistryObject<Item> PIN = register("pin");
    public static final RegistryObject<Item> INSULATION = register("insulation", 0xc2c4a2);

    //材料-高级
    public static final RegistryObject<Item> UN_ENCAPSULATION_SHIELD = register("un_encapsulation_shield", NonFunctionItem::new);
    //电路板
    public static final RegistryObject<Item> CIRCUITS_BASIC = ITEMS.register("circuits_basic", NonFunctionItem::new);
    public static final RegistryObject<Item> CIRCUITS_ADVANCED = ITEMS.register("circuits_advanced", NonFunctionItem::new);
    public static final RegistryObject<Item> CIRCUITS_ELITE = ITEMS.register("circuits_elite", NonFunctionItem::new);
    //激发器
    public static final RegistryObject<Item> EXCITER_1KV = register("exciter_1kv", NonFunctionItem::new);
    public static final RegistryObject<Item> EXCITER_2KV = register("exciter_2kv", NonFunctionItem::new);
    public static final RegistryObject<Item> EXCITER_5KV = register("exciter_5kv", NonFunctionItem::new);
    //限制器
    public static final RegistryObject<Item> NORMAL_LIMITER = register("normal_limiter", NonFunctionItem::new);
    public static final RegistryObject<Item> ADVANCE_LIMITER = register("advance_limiter", NonFunctionItem::new);
    public static final RegistryObject<Item> EXPERT_LIMITER = register("expert_limiter", NonFunctionItem::new);
    //引导芯片
    public static final RegistryObject<Item> RED_STONE_ENERGY_GUIDER = register("red_stone_energy_guider", NonFunctionItem::new);
    public static final RegistryObject<Item> GOLD_PLATING_ENERGY_GUIDER = register("gold_plating_energy_guider", NonFunctionItem::new);
    public static final RegistryObject<Item> SUPERCONDUCTION_ENERGY_GUIDER = register("superconduction_energy_guider", NonFunctionItem::new);
    //电容
    public static final RegistryObject<Item> ALUMINUM_ELECTROLYTIC_CAPACITOR = register("aluminum_electrolytic_capacitor", NonFunctionItem::new);
    public static final RegistryObject<Item> TANTALUM_CAPACITOR = register("tantalum_capacitor", NonFunctionItem::new);
    public static final RegistryObject<Item> NANO_MNO2_CAPACITANCE = register("nano_mno2_capacitance", NonFunctionItem::new);
    //cpu
    public static final RegistryObject<Item> L_1H_CPU = register("l_1h_cpu", NonFunctionItem::new);
    public static final RegistryObject<Item> L_2K_1000_CPU = register("l_2k_1000_cpu", NonFunctionItem::new);
    public static final RegistryObject<Item> L_3A_5000_CPU = register("l_3a_5000_cpu", NonFunctionItem::new);
    //内存
    public static final RegistryObject<Item> C_R3_MEMORY = register("c_r3_memory", NonFunctionItem::new);
    public static final RegistryObject<Item> C_R4_MEMORY = register("c_r4_memory", NonFunctionItem::new);
    public static final RegistryObject<Item> C_R5_MEMORY = register("c_r5_memory", NonFunctionItem::new);
    //线缆
    public static final RegistryObject<Item> ENVIRONMENTAL_CABLE = register("environmental_cable", () -> new NonFunctionItem(i18Tex("tooltip.ae.shield.cable1").mergeStyle(TextFormatting.GRAY), i18Tex("tooltip.ae.shield.cable2").mergeStyle(TextFormatting.GRAY), i18Tex("tooltip.ae.shield.cable3").mergeStyle(TextFormatting.GRAY)));
    public static final RegistryObject<Item> POLYMERIC_CABLE = register("polymeric_cable", NonFunctionItem::new);
    public static final RegistryObject<Item> NANO_CABLE = register("nano_cable", NonFunctionItem::new);

    public static final RegistryObject<Item> SLC_PARTICLE_PRODUCER = register("slc_particle_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> MLC_PARTICLE_PRODUCER = register("mlc_particle_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> TLC_PARTICLE_PRODUCER = register("tlc_particle_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> MINI_PHASE_TRANSFER_SURFACE = register("mini_phase_transfer_surface", NonFunctionItem::new);
    public static final RegistryObject<Item> SLC_PHASE_TRANSFER_SURFACE = register("slc_phase_transfer_surface", NonFunctionItem::new);
    public static final RegistryObject<Item> MLC_PHASE_TRANSFER_SURFACE = register("mlc_phase_transfer_surface", NonFunctionItem::new);
    public static final RegistryObject<Item> TLC_PHASE_TRANSFER_SURFACE = register("tlc_phase_transfer_surface", NonFunctionItem::new);
    public static final RegistryObject<Item> MINI_PLASMA_PRODUCER = register("mini_plasma_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> SLC_PLASMA_PRODUCER = register("slc_plasma_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> MLC_PLASMA_PRODUCER = register("mlc_plasma_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> TLC_PLASMA_PRODUCER = register("tlc_plasma_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> MINI_FIELD_PRODUCER = register("mini_field_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> SLC_FIELD_PRODUCER = register("slc_field_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> MLC_FIELD_PRODUCER = register("mlc_field_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> TLC_FIELD_PRODUCER = register("tlc_field_producer", NonFunctionItem::new);
    public static final RegistryObject<Item> SLC_NANO_ROBOT_FACTORY = register("slc_nano_robot_factory", NonFunctionItem::new);
    public static final RegistryObject<Item> MLC_NANO_ROBOT_FACTORY = register("mlc_nano_robot_factory", NonFunctionItem::new);
    public static final RegistryObject<Item> TLC_NANO_ROBOT_FACTORY = register("tlc_nano_robot_factory", NonFunctionItem::new);
    public static final RegistryObject<Item> A_PART_OF_MAGIC_SPELL = register("a_part_of_magic_spell", NonFunctionItem::new);
    public static final RegistryObject<Item> ROOKIE_MAGIC_SPELL = register("rookie_magic_spell", NonFunctionItem::new);
    public static final RegistryObject<Item> PRACTISED_MAGIC_SPELL = register("practised_magic_spell", NonFunctionItem::new);
    public static final RegistryObject<Item> MASTER_MAGIC_SPELL = register("master_magic_spell", NonFunctionItem::new);
    public static final RegistryObject<Item> HEV_ELEMENTS_1ST = register("hev_elements_1st", NonFunctionItem::new);
    public static final RegistryObject<Item> HEV_ELEMENTS_3RD = register("hev_elements_3rd", NonFunctionItem::new);
    public static final RegistryObject<Item> HEV_ELEMENTS_4TH = register("hev_elements_4th", NonFunctionItem::new);
    public static final RegistryObject<Item> HEV_ELEMENTS_5TH = register("hev_elements_5th", NonFunctionItem::new);
    public static final RegistryObject<Item> TRANSFORMED_TOTEM = register("transformed_totem", NonFunctionItem::new);
    public static final RegistryObject<Item> BLESSED_TOTEM = register("blessed_totem", NonFunctionItem::new);
    public static final RegistryObject<Item> SACRED_TOTEM = register("sacred_totem", NonFunctionItem::new);
    public static final RegistryObject<Item> COLLECTION_SYSTEM = register("collection_system", NonFunctionItem::new);
    public static final RegistryObject<Item> PULVERIZE_SYSTEM = register("pulverize_system", NonFunctionItem::new);
    public static final RegistryObject<Item> REGROUP_SYSTEM = register("regroup_system", NonFunctionItem::new);
    public static final RegistryObject<Item> SPEED_CORE = register("speed_core", NonFunctionItem::new);
    public static final RegistryObject<Item> UNPROGRAMMED_NANO_ROBOT = register("unprogrammed_nano_robot", NonFunctionItem::new);
    public static final RegistryObject<Item> UNPROGRAMMED_KID = register("unprogrammed_kid", NonFunctionItem::new);
    public static final RegistryObject<Item> UNPROGRAMMED_INTENSIFIED_KID = register("unprogrammed_intensified_kid", NonFunctionItem::new);

    //工具
    public static final RegistryObject<Item> HAMMER = register("hammer", ToolItem::new);
    public static final RegistryObject<Item> SCREWDRIVER = register("screwdriver", ToolItem::new);
    public static final RegistryObject<Item> SOLDERING_IRON = register("soldering_iron", ToolItem::new);
    public static final RegistryObject<Item> MORTAR = register("mortar", ToolItem::new);
    public static final RegistryObject<Item> SHEAR = register("shear", ToolItem::new);

    //------------------------------------------------------BUCKET------------------------------------------------------
    public static final RegistryObject<Item> NITROGEN_FLUID_BUCKET = register("nitrogen_bucket", () -> NitrogenFluid.NitrogenFluidBucket);

    //方块
    //矿石
    public static final RegistryObject<Item> ORES_TIN = register("ores_tin", () -> new BlockItem(BlockList.ORES_TIN.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> ORES_LEAD = register("ores_lead", () -> new BlockItem(BlockList.ORES_LEAD.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> ORES_ALUMINUM = register("ores_aluminum", () -> new BlockItem(BlockList.ORES_ALUMINUM.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> ORES_SILVER = register("ores_silver", () -> new BlockItem(BlockList.ORES_SILVER.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> ORES_MANGANESE = register("ores_manganese", () -> new BlockItem(BlockList.ORES_MANGANESE.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> ORES_TANTALUM = register("ores_tantalum", () -> new BlockItem(BlockList.ORES_TANTALUM.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    //设备
    public static final RegistryObject<Item> ASSEMBLY_BLOCK = register("assembly_block", () -> new BlockItem(BlockList.ASSEMBLY_BLOCK.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> SHIELD_WORKBENCH_BLOCK = register("shield_workbench_block", () -> new BlockItem(BlockList.SHIELD_WORKBENCH_BLOCK.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));
    public static final RegistryObject<Item> NANO_ROBOT_PROGRAMMER_BLOCk = register("nano_robot_programmer_block", () -> new BlockItem(BlockList.NANO_ROBOT_PROGRAMMER.get(), new Item.Properties().group(AEShieldMod.AE_SHIELD)));

//------------------------------------------------------特殊物品----------------------------------------------------------

    public static final RegistryObject<Item> RENDER_ITEM = register("render_item", RenderItem::new);
//----------------------------------------------------------------------------------------------------------------------

    public static TranslationTextComponent i18Tex(String key) {
        return new TranslationTextComponent(key);
    }

    /**
     * 普通注册
     */
    public static RegistryObject<Item> register(String name, Supplier<? extends Item> sup) {
        return ITEMS.register(name, sup);
    }

    /**
     * 无功能物品默认注册
     */
    public static RegistryObject<Item> register(String name) {
        return register(name, NonFunctionItem::new);
    }

    /**
     * 着色物品注册
     */
    public static RegistryObject<Item> register(String name, int color) {
        RegistryObject<Item> item = ITEMS.register(name, () -> new ColorItem(color));
        COLOR.add(item);
        return item;
    }
}
